package com.flowerSystem.mapper;

import com.flowerSystem.entity.Shoppingcart;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.flowerSystem.pojo.ShoppingcartPojo;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 鲜花遇上牛战士
 * @since 2023-08-28
 */
public interface ShoppingCartMapper extends BaseMapper<Shoppingcart> {

    @Update("update shoppingcart set order_count = order_count+1 where id = #{id}")
    int plusOrderCountById(int id);

    @Update("update shoppingcart set order_count = order_count-1 where id = #{id}")
    int reduceOrderCountById(int id);

    @Select("select id,product_information_id,user_id,order_count from shoppingcart where id = #{id}")
    Shoppingcart getOrderCountById(int id);

//    @Select("select s.id,s.order_count," +
//            "p.flower_name,p.price,p.flower_language,p.img," +
//            "p.hot,p.discribe,e.classify,p.amount " +
//            "from productInformation p " +
//            "left join shoppingcart s on s.productInformation_id = p.id " +
//            "left join user u on s.user_id = u.id " +
//            "left join producttype e on e.id = p.product_type_id where s.user_id = #{userId}")
//@Select("select * from productInformation p " +
//        "left join shoppingcart s on s.productInformation_id = p.id " +
//        "left join user u on s.user_id = u.id " +
//        "left join producttype e on e.id = p.product_type_id where s.user_id = #{userId}")
    List<ShoppingcartPojo> getShopOrderAll(int userId);
}
